import logging

import pytest
from selenium import webdriver
from Page.Page import Page
from Tools.Tools import rizhi
from Page.Mysql import Mysql
from time import sleep
from Tools.Tools import read
data = read('./data.yaml')
# class Test_a3mall():
@pytest.fixture
def driver():
    logging.info('开始')
    driver = webdriver.Edge()
    driver.get('http://10.59.9.12:7001/')
    driver.maximize_window()
    yield driver
    sleep(8)
    driver.quit()
    logging.info('结束')
@pytest.mark.parametrize('datas',data)
def test_login(driver,datas):
    logging.info('start')
    db = Mysql(host='10.59.9.12', user='root', password='yidong666', database='a3mall')
    po = Page(driver)
    po.login_loc()
    print(po.dy1_loc())
    po.user_name(datas.get('username'))
    po.password_loc(datas.get('password'))
    sleep(10)
    po.login1_loc()
    a = db.chaxun('select amount from mall_users where username=15232008902')
    print(a)
    a1= po.dy2_loc().split()[1]
    print(a1)
    assert float(a[0][0]) ==float(a1)
    sleep(5)
    po.sousuo_loc()
    po.sousuo_loc1()
    logging.info('end')





